//
//  ZHMineTableView.m
//  LoveFreshBee
//
//  Created by brice Mac on 2016/10/15.
//  Copyright © 2016年 王忠迪. All rights reserved.
//

#import "ZHMineTableView.h"
#import "ZHMineCell.h"
#import "ZHMineModel.h"

@interface ZHMineTableView ()<UITableViewDataSource>

@property(nonatomic,strong)NSArray<ZHMineModel *> *dataArray;

@end

@implementation ZHMineTableView

- (NSArray<ZHMineModel *> *)dataArray {
    if (_dataArray == nil) {
        _dataArray = [ZHMineModel loadMineCellModels];
    }
    return _dataArray;
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    self = [super initWithFrame:frame style:style];
    if (self) {
        
        [self registerClass:[ZHMineCell class] forCellReuseIdentifier:@"MineCellId"];
        self.dataSource = self;
        self.rowHeight = 50;
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return self;
}

#pragma mark - data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (0 == section) {
        return 2;
    } else if (1 == section) {
        return 1;
    } else {
        return 2;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ZHMineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineCellId" forIndexPath:indexPath];
    
    if (indexPath.section == 0) {
        cell.model = self.dataArray[indexPath.row];
    } else if (indexPath.section == 1) {
        cell.model = self.dataArray[2];
    } else {
        if (indexPath.row == 0) {
            cell.model = self.dataArray[3];
        } else {
            cell.model = self.dataArray[4];
        }
    }
    
    UIImageView *iconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_go"]];
    cell.accessoryView = iconImgView;
    
    return cell;
}


@end





